﻿using SolidWorks.Interop.sldworks;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SolidworksDLL
{
    /// <summary>
    /// 配置帮助类
    /// </summary>
    class ConfigurationHelp
    {
        /// <summary>
        /// 获取当前配置
        /// </summary>
        /// <param name="swModel"></param>
        /// <returns></returns>
        public static Configuration GetCurCfg(ModelDoc2 swModel)
        {
            ConfigurationManager cfgMgr = swModel.ConfigurationManager;
            return cfgMgr.ActiveConfiguration;
        }

        /// <summary>
        /// 获取所有配置
        /// </summary>
        /// <param name="swModel"></param>
        /// <returns></returns>
        public static List<Configuration> GetAllCfg(ModelDoc2 swModel)
        {
            List<Configuration> cfgs = new List<Configuration>();

            string[] cfgNames = swModel.GetConfigurationNames();
            foreach (var item in cfgNames)
            {
                Configuration cfg = swModel .GetConfigurationByName(item);
                if (null != cfg)
                {
                    cfgs.Add(cfg);
                }
            }
            return cfgs;

        }
    }
}
